package edu.gatech.doi.spamframework.mapping;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Date;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.converters.ArffSaver;

import edu.gatech.doi.spamframework.core.MappingXMLFiles;
import edu.gatech.doi.spamframework.core.ModelXMLFiles;
import edu.gatech.doi.spamframework.model.Message;
import edu.gatech.doi.spamframework.model.ModelAttribute;

import edu.gatech.doi.spamframework.model.XMLOperator;


public class MySpaceMapper implements Mapper {

	private HashMap mapping;
	
	private String instancesdirectory=System.getProperties().getProperty("user.dir")+System.getProperties().getProperty("file.separator")+"instances"+System.getProperties().getProperty("file.separator");
	
	private String modelsdirectory=System.getProperties().getProperty("user.dir")+System.getProperties().getProperty("file.separator")+"models"+System.getProperties().getProperty("file.separator");
	
	private String propertiesdirectory=System.getProperties().getProperty("user.dir")+System.getProperties().getProperty("file.separator")+"properties"+System.getProperties().getProperty("file.separator");
	private String datasetsdirectory=System.getProperties().getProperty("user.dir")+System.getProperties().getProperty("file.separator")+"datasets"+System.getProperties().getProperty("file.separator")+"myspace"+System.getProperties().getProperty("file.separator");
	
	
	private String mappingsdirectory=System.getProperties().getProperty("user.dir")+System.getProperties().getProperty("file.separator")+"mappings"+System.getProperties().getProperty("file.separator");
	
	private String personmodelfilename="personmodel.xml";
	
	private String messagemodelfilename="messagemodel.xml";
	
	private String personmappingfilename="myspacepersonmapping.xml";
	
	private HashMap personmodelhm;
	
	private HashMap personmappinghm;
	
	private HashMap messagemodelhm;
	
	private HashMap messagemappinghm;
	
	private String myspacepersonarfffilename;
	
	Instances       data = null;
	
	//0: append; 1: replace
	private int isappended=0;
	
	private int limit=0;
	
	private String labelvalue;
	
	public MySpaceMapper()
	{
		
	}
	
	
	public void init()
	{	
		// load property file for myspace
		
		String filepath0=this.propertiesdirectory+"myspace.properties";
//		System.out.println(filepath0);
		PropertiesFileOperator pfo=new PropertiesFileOperator(filepath0);
		pfo.load();
		HashMap mhm=ModelXMLFiles.getMap();
		HashMap mappinghm=MappingXMLFiles.getMap("MYSPACE");
		this.messagemodelfilename=(String) mhm.get("MESSAGE");
		
		this.personmappingfilename=(String) mappinghm.get("MYSPACE.PERSON");
		
		this.personmodelfilename=(String) mhm.get("PERSON");
		this.myspacepersonarfffilename=pfo.getProperty("PERSONARFF");
		this.isappended=Integer.parseInt(pfo.getProperty("ISAPPENDED"));
		this.labelvalue=pfo.getProperty("LABEL");
		this.limit=Integer.parseInt(pfo.getProperty("LIMIT"));
//		System.out.println(this.messagemodelfilename+" "+this.personmappingfilename+" "+this.personmodelfilename);
		
		// load models and mappings
		XMLOperator xmlo=new XMLOperator();
		//person models
		String filepath1=this.modelsdirectory+this.personmodelfilename;
		this.personmodelhm=new HashMap();
//		System.out.println("filepath:"+filepath);
		this.personmodelhm=xmlo.getModelAttrsFromXML(filepath1);
//		if(this.personmodelhm==null)
//		{
//			System.out.println("personmappinghm is null");
//		}
		String filepath2=this.mappingsdirectory+this.personmappingfilename;
		this.personmappinghm=new HashMap();
		this.personmappinghm=xmlo.getMappingAttrsFromXML(filepath2);
//		this.myspacepersonarfffilename="myspaceperson.arff";
		
	}
	
	public void parsePersonsFromIndexFile(String indexFileName)
	{
		File file=new File(indexFileName);
		
		if(file.exists())
		{
			try {
				FileReader fis=new FileReader(file);
				BufferedReader bis=new BufferedReader(fis);
				String line;
				while((line=bis.readLine())!=null)
				{
					this.parsePersons(line);
				}
				
				
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		else
		{
			System.out.println("Index File does not exist!!!");
			
		}
	}
	
	public void parseMessagesFromIndexFile(String indexFileName)
	{
		File file=new File(indexFileName);
		
		if(file.exists())
		{
			try {
				FileReader fis=new FileReader(file);
				BufferedReader bis=new BufferedReader(fis);
				String line;
				while((line=bis.readLine())!=null)
				{
					this.parseMessages(line);
				}
				
				
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		else
		{
			System.out.println("Index File does not exist!!!");
			
		}
	}
	
	
	@Override
	public Instances parsePersons(String personFile) {
		// TODO Auto-generated method stub
		
		FastVector      atts;
		
		
		// 1. set up attributes
		
		/**
		 * attributes list
		 */
		
		ArrayList attributelist=new ArrayList();
		Iterator attrit=this.personmappinghm.keySet().iterator();
		HashMap mappingattrhm=new HashMap();
		while(attrit.hasNext())
		{
			String tempattrstr=(String) attrit.next();
			attributelist.add(tempattrstr);
			MappingAttribute mappinga=(MappingAttribute) this.personmappinghm.get(tempattrstr);
			mappingattrhm.put(mappinga.getModelAttributeName(), mappinga);
		}
		
	    atts = new FastVector();
	   
	    //get model attributes
	   
//	    HashMap hm=this.personmodelhm;
	    Set personmodelkeyset= this.personmodelhm.keySet();
		   List list=new ArrayList(personmodelkeyset);
		   Collections.sort(list);
		    Iterator it=list.iterator();
	    while(it.hasNext())
	    {
	    	String tempstr=(String)it.next();
//	    	System.out.println("tempstr1="+tempstr);
	    	ModelAttribute attribute=(ModelAttribute) this.personmodelhm.get(tempstr.trim());
	    	String attributename=attribute.getAttributeName();
//	    	System.out.println("attributename:"+attributename);
	    	int typeid=attribute.getAttributeTypeId();
	    	
	    	switch(typeid)
	    	{
	    	case 1:
	    		//-numeric
	    		
	    		atts.addElement(new Attribute(attributename));
	    		break;
	    	case 2:
	    		//-nominal
	    		FastVector attVals;
	    	    attVals = new FastVector();
	    	    ArrayList al=attribute.getNomialValues();
	    	    Iterator ital=al.iterator();
	    	    while(ital.hasNext())
	    	    {
	    	    	String alstr=(String) ital.next();
	    	    	attVals.addElement(alstr);
	    	    }
	    	    atts.addElement(new Attribute(attributename, attVals));
	    	    break;
	    		
	    	case 3:
	    		//-string
	    		atts.addElement(new Attribute(attributename, (FastVector) null));
	    		break;
	    	case 4:
	    		//-date
	    	    atts.addElement(new Attribute(attributename, (FastVector) null));
	    	    break;
	    	}
	    }
	    
	    // instance_id and label
	    Attribute instanceid=new Attribute("INSTANCE_ID", (FastVector) null);
	    Attribute label=new Attribute("LABEL", (FastVector) null);
	    atts.addElement(instanceid);
	    atts.addElement(label);
	    // 2. create Instances object
	    
	    data = new Instances("MySpacePersons", atts, 0);
	    // 3. fill with data
	    HashMap hm=this.personMapping(attributelist);
		/**
		 * XML parser
		 */
	    File file=new File(personFile);
	    
	    //create file
		String arfffilename=this.instancesdirectory+this.myspacepersonarfffilename;   
	    File arfffile=new File(arfffilename);
	    if(!arfffile.exists())
	    {
	    	try {
	    		arfffile.createNewFile();
			 	this.save2arff(data, this.instancesdirectory, this.myspacepersonarfffilename);
 
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    }
	    else
	    {
	    	try {
		    	if(this.isappended==1)
	    		{
					arfffile.delete();
					arfffile.createNewFile();
				 	this.save2arff(data, this.instancesdirectory, this.myspacepersonarfffilename);
	    		}
	    	
    		} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    }
	    //arff file writer
	    FileWriter writer = null;
	    BufferedWriter bw=null;
	    int totalnum=0;
	    if(file.isDirectory())
	    {
	    	// it is a directory
	    	
	    	//process each file one by one
	    	File[] filelist=file.listFiles();
	    	SAXBuilder builder = new SAXBuilder();
	    	for(int j=0;j<filelist.length;j++)
	    	{
	    		 try {
	 	        	
	 	        	
	 	        	//single file
	    			 
	    			String tempfilename=filelist[j].getPath();
	    			
	    			FileInputStream fis = new FileInputStream(tempfilename);
	    			InputStreamReader isr = new InputStreamReader(fis, "UTF8");

//	    			System.out.println(isr.getEncoding());
	    			
	    			
	 				Document doc = builder.build(isr);
	 				Element root = doc.getRootElement();
	 				HashMap inhm=new HashMap();
	 				/**
	 				 * url,name,sex,age,location,interests_text,about_me,profileethnicity,profilestatus
	 				 */
	 				Iterator it1=attributelist.iterator();
	 				while(it1.hasNext())
	 				{
	 					String attstr=(String)it1.next();
	 					String rows = null;
	 					if(attstr.toLowerCase().contains("."))
	 					{
//	 						System.out.println("attstr.toLowerCase():"+attstr.toLowerCase());
	 						String tempstr=attstr.toLowerCase();
//	 						System.out.println("tempstr:"+tempstr);
	 						String [] substrs =tempstr.split("\\.");
//	 						System.out.println("substrs:"+substrs.length);
	 						Element tempparent=root.getChild(substrs[0]);
	 						for(int i=1;i<substrs.length;i++)
	 						{
	 							if(i==substrs.length-1)
	 							{
	 								rows=tempparent.getChildTextTrim(substrs[i]);
	 							}
	 							tempparent=tempparent.getChild(substrs[i]);
	 							
	 						}
//	 						rows=root.getChild(substrs).getChildTextTrim(attstr.toLowerCase());
	 					}
	 					else
	 					{
	 						rows=root.getChildTextTrim(attstr.toLowerCase());
	 					}
	 					ModelAttribute attribute=(ModelAttribute)hm.get(attstr);
	 			    	String attributename=attribute.getAttributeName();
	 					inhm.put(attributename.trim(), rows);
//	 					System.out.println("child:"+attributename.trim()+": "+rows);
	 				}
	 			    Instance newInst = new Instance(data.numAttributes());

	 				for(int i=0;i<data.numAttributes();i++)
	 				{
//	 					System.out.println("i="+data.numAttributes());
	 					if(inhm.containsKey(data.attribute(i).name()))
	 					{
	 					 //-numeric
	 					   if(data.attribute(i).isNumeric())
	 					   {
	 						   String tempstr=(String) inhm.get(data.attribute(i).name());
							   
							   if(tempstr==null)
							   {
								 newInst.setMissing(data.attribute(i));
							   }
							   else
							   {
								   double tempd=Double.valueOf(tempstr);
								   newInst.setValue(data.attribute(i),tempd);
							   }
	 					   }
	 					   //-nominal
	 					   if(data.attribute(i).isNominal())
	 					   {
	 						   MappingAttribute mapa=(MappingAttribute) mappingattrhm.get(data.attribute(i).name());
							   ModelAttribute modela=(ModelAttribute) hm.get(mapa.getAttributeName());
							   String tempstr=(String) inhm.get(data.attribute(i).name());
							   ArrayList modelal=modela.getNomialValues();
							   ArrayList mappingal=mapa.getNomialValues();
							   HashMap mappingnominal=new HashMap();
							   for(int n=0;n<modelal.size();n++)
							   {
//								   System.out.println("mapping:"+mappingal.get(n)+ modelal.get(n));
								   mappingnominal.put(mappingal.get(n), modelal.get(n));
							   }
							   String tempmapstr=(String)mappingnominal.get(tempstr);
							   if(tempmapstr==null)
							   {
								   newInst.setMissing(data.attribute(i));
							   }
							   else
							   newInst.setValue(data.attribute(i),tempmapstr);
	 					   }
	 					   //-string
	 					   if(data.attribute(i).isString())
	 					   {
	 						   System.out.println("--"+data.attribute(i).name());
	 						   String tempstr=(String)inhm.get(data.attribute(i).name());
	 						   System.out.println(tempstr);
	 						  if(tempstr==null)
	 							  newInst.setMissing(data.attribute(i));
	 						  else
	 						   newInst.setValue(data.attribute(i),tempstr);
	 							
//	 						   vals[i] = data.attribute(i).addStringValue("This is a string!");
	 					   }
	 				   
	 					   //-date
	 					   if(data.attribute(i).isDate())
	 					   {
	 						  String tempstr=(String)inhm.get(data.attribute(i).name());
	 						 if(tempstr==null)
	 							  newInst.setMissing(data.attribute(i));
	 						  else
	 						   newInst.setValue(data.attribute(i),tempstr);
//	 						   newInst.setValue(data.attribute(i),(String) inhm.get(data.attribute(i).name()) );
	 							
//	 						   try {
//	 							vals[i] = data.attribute(i).parseDate("2001-11-09");
//	 						} catch (ParseException e) {
//	 							// TODO Auto-generated catch block
//	 							e.printStackTrace();
//	 						}
	 					   }
	 					}
	 				}
	 				
	 				
	 				//instanceid;
//	 				System.out.println(personFile);
	 			
	 				int index1=tempfilename.lastIndexOf("\\");
	 				int index2=tempfilename.lastIndexOf(".");
//	 				System.out.println("index1"+index1+" index2:"+index2);
	 				String instanceidstr="MySpace_"+tempfilename.substring(index1+1, index2);
	 				
	 				newInst.setValue(data.attribute(data.numAttributes()-2), instanceidstr);
	 				if(this.labelvalue.equalsIgnoreCase("spam"))
	 					newInst.setValue(data.attribute(data.numAttributes()-1), "spam");
	 				if(this.labelvalue.equalsIgnoreCase("ham"))
	 					newInst.setValue(data.attribute(data.numAttributes()-1), "ham");
	 				// add
	 			     data.add(newInst);
	 			    
	 			    // first time saving 
	 			
	 			   
	 			    
	 			   
	 			
	 			    	 //append new instance to the file
	 			    	
	 			    	writer =new FileWriter(arfffilename, true);
	 			    	
	 				    bw=new BufferedWriter(writer);
	 				    try {
	 				    	
	 				    	  // You are now at the end of the file,
	 				    	  // and can start writing new data out, e.g.
	 				    	 bw.newLine(); 
	 				    	 for(int i=0;i<data.numInstances();i++)
	 				    	 {
	 				    		 bw.write(data.instance(i).toString());
	 				    		 bw.newLine();
	 				    		 bw.flush();
	 				    	 }
	 				    	 bw.close();
	 				    	 writer.close();
	 				    	 bw=null;
	 				    	 writer=null;
	 				    	} catch (IOException ex ) {
	 				    	  ex.printStackTrace();
	 				    	}finally {                       // always close the file
	 				    		 if (bw != null) try {
	 				    		    bw.close();
	 				    		 } catch (IOException ioe2) {
	 				    		    // just ignore it
	 				    		 }
	 				    	 }
	 				    	// delete instances in data
	 				    data.delete();
	 			       
	 			      totalnum++;
	 			      
	 				   fis.close();
				    	isr.close();
				    	System.out.println("limit="+this.limit+" totalnum="+totalnum);
				    if(this.limit!=0&&totalnum>this.limit)
		 			   break;

	 			} catch (JDOMException e) {
	 				// TODO Auto-generated catch block
	 				e.printStackTrace();
	 			} catch (IOException e) {
	 				// TODO Auto-generated catch block
	 				e.printStackTrace();
	 			}
	    	}
	    	
	
	    }
	    else
	    {
	    	// a file
	    	SAXBuilder builder = new SAXBuilder();
	        try {
	        	FileInputStream fis = new FileInputStream(personFile);
    			InputStreamReader isr = new InputStreamReader(fis, "UTF8");
	        	//single file
				Document doc = builder.build(isr);
				Element root = doc.getRootElement();
				HashMap inhm=new HashMap();
				/**
				 * url,name,sex,age,location,interests_text,about_me,profileethnicity,profilestatus
				 */
				Iterator it1=attributelist.iterator();
				while(it1.hasNext())
				{
					String attstr=(String)it1.next();
					String rows = null;
					if(attstr.toLowerCase().contains("."))
					{
//						System.out.println("attstr.toLowerCase():"+attstr.toLowerCase());
						String tempstr=attstr.toLowerCase();
//						System.out.println("tempstr:"+tempstr);
						String [] substrs =tempstr.split("\\.");
//						System.out.println("substrs:"+substrs.length);
						Element tempparent=root.getChild(substrs[0]);
						for(int i=1;i<substrs.length;i++)
						{
							if(i==substrs.length-1)
							{
								rows=tempparent.getChildTextTrim(substrs[i]);
							}
							tempparent=tempparent.getChild(substrs[i]);
							
						}
//						rows=root.getChild(substrs).getChildTextTrim(attstr.toLowerCase());
					}
					else
					{
						rows=root.getChildTextTrim(attstr.toLowerCase());
					}
					ModelAttribute attribute=(ModelAttribute)hm.get(attstr);
			    	String attributename=attribute.getAttributeName();
					inhm.put(attributename.trim(), rows);
//					System.out.println("child:"+attributename.trim()+": "+rows);
				}
			    Instance newInst = new Instance(data.numAttributes());

				for(int i=0;i<data.numAttributes();i++)
				{
//					System.out.println("i="+data.numAttributes());
					if(inhm.containsKey(data.attribute(i).name()))
					{
					 //-numeric
					   if(data.attribute(i).isNumeric())
					   {
						   String tempstr=(String) inhm.get(data.attribute(i).name());
						   
						   if(tempstr==null)
						   {
							 newInst.setMissing(data.attribute(i));
						   }
						   else
						   {
							   double tempd=Double.valueOf(tempstr);
							   newInst.setValue(data.attribute(i),tempd);
						   }
						  
						   
					   }
					   //-nominal
					   if(data.attribute(i).isNominal())
					   {
						   
						   MappingAttribute mapa=(MappingAttribute) mappingattrhm.get(data.attribute(i).name());
						   ModelAttribute modela=(ModelAttribute) hm.get(mapa.getAttributeName());
						   String tempstr=(String) inhm.get(data.attribute(i).name());
						   ArrayList modelal=modela.getNomialValues();
						   ArrayList mappingal=mapa.getNomialValues();
						   HashMap mappingnominal=new HashMap();
						   for(int n=0;n<modelal.size();n++)
						   {
//							   System.out.println("mapping:"+mappingal.get(n)+ modelal.get(n));
							   mappingnominal.put(mappingal.get(n), modelal.get(n));
						   }
//						   System.out.println(tempstr);
						   String tempmapstr=(String)mappingnominal.get(tempstr);
						   if(tempmapstr==null)
						   {
							   newInst.setMissing(data.attribute(i));
						   }
						   else
						   newInst.setValue(data.attribute(i),tempmapstr);
					   }
					   //-string
					   if(data.attribute(i).isString())
					   {
//						   System.out.println("--"+data.attribute(i).name());
						   String tempstr=(String)inhm.get(data.attribute(i).name());
//						   System.out.println(tempstr);
						   if(tempstr==null)
	 							  newInst.setMissing(data.attribute(i));
	 						  else
	 						   newInst.setValue(data.attribute(i),tempstr);
//						   newInst.setValue(data.attribute(i),tempstr);
							
//						   vals[i] = data.attribute(i).addStringValue("This is a string!");
					   }
				   
					   //-date
					   if(data.attribute(i).isDate())
					   {
						   String tempstr=(String)inhm.get(data.attribute(i).name());
						   if(tempstr==null)
	 							  newInst.setMissing(data.attribute(i));
	 						  else
	 						   newInst.setValue(data.attribute(i),tempstr);
//						   newInst.setValue(data.attribute(i),(String) inhm.get(data.attribute(i).name()) );
							
//						   try {
//							vals[i] = data.attribute(i).parseDate("2001-11-09");
//						} catch (ParseException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						}
					   }
					}
				}
				
				
				//instanceid;
//				System.out.println(personFile);
				int index1=personFile.lastIndexOf("\\");
				int index2=personFile.lastIndexOf(".");
//				System.out.println("index1"+index1+" index2:"+index2);
				String instanceidstr="MySpace_"+personFile.substring(index1+1, index2);
				
				newInst.setValue(data.attribute(data.numAttributes()-2), instanceidstr);
				
				if(this.labelvalue.equalsIgnoreCase("spam"))
 					newInst.setValue(data.attribute(data.numAttributes()-1), "spam");
 				if(this.labelvalue.equalsIgnoreCase("ham"))
 					newInst.setValue(data.attribute(data.numAttributes()-1), "ham");
				
				// add
			     data.add(newInst);
			     this.save2arff(data, this.instancesdirectory, this.myspacepersonarfffilename);
			    	data.delete();
//			     System.out.println(data.lastInstance().toString());
			    	fis.close();
			    	isr.close();

			} catch (JDOMException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
	    }
		
		
		
		return data;
	}

	@Override
	public Instances parseMessages(String msgFile) {
		// TODO Auto-generated method stub
		return null;
	}
	
	
	
	/**
	 * attributes mapping
	 * @param attr
	 * @return
	 */
		public HashMap personMapping(ArrayList attr)
		{
			
			HashMap hm=new HashMap();
			Iterator it=attr.iterator();
			while(it.hasNext())
			{
				String tempstr=(String) it.next();
//				System.out.println("personMapping tempstr="+tempstr);
				/**
				 * url,name,sex,age,location,interests_text,about_me,profileethnicity,profilestatus
				 */
				MappingAttribute maa=(MappingAttribute)(this.personmappinghm.get(tempstr));
				String modelattributename=maa.getModelAttributeName();
//				System.out.println("modelattributename:"+modelattributename);
				ModelAttribute ma=(ModelAttribute)this.personmodelhm.get(modelattributename);

//				System.out.println("ma.getattributename:"+ma.getAttributeName());
				hm.put(tempstr,ma);
			}
			return hm;
			
		}
		
		
		/**
		 * attributes mapping
		 * @return
		 */
		public HashMap messageMapping(ArrayList attr)
		{

			return null;


		}
		
	
    public void append2arff(String personFile,String arfffilename, String filedirectory, String filename)
    {
    	
    }

	/**
	 * save instances to arff files
	 * @param in
	 * @param filedirectory
	 * @param filename
	 */
	public void save2arff(Instances in, String filedirectory, String filename)
	{
		 Instances dataSet =in;
		 ArffSaver saver = new ArffSaver();
		 saver.setInstances(dataSet);
		 try {
			saver.setFile(new File(filedirectory+System.getProperties().getProperty("file.separator")+filename));
		//	saver.setDestination(new File("./data/test.arff"));   // **not** necessary in 3.5.4 and later
			 saver.writeBatch();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 
	}
	
	public String getInstancesdirectory() {
		return instancesdirectory;
	}


	public void setInstancesdirectory(String instancesdirectory) {
		this.instancesdirectory = instancesdirectory;
	}


	public int getIsappended() {
		return isappended;
	}


	public void setIsappended(int isappended) {
		this.isappended = isappended;
	}


	public static void main(String [] arg0)
	{
		MySpaceMapper msm=new MySpaceMapper();
		String personFile=msm.datasetsdirectory+"test.xml";
		msm.init();
		Instances ins=msm.parsePersons(personFile);
//		msm.save2arff(ins, msm.getInstancesdirectory(), "test1.arff");
	}
	
}
